<?php
require_once 'Dsql.php';

$maxLength = 40;

    //------- facebook
    $app_id = '178102922208034';
    $canvas_page = 'http://apps.facebook.com/manyaphorisms/';
    //------- facebook
    $db = new Dsql("mysql-88.ukraine.com.ua", "barthez_ai", "x9gedv4w");

    $db->selectDb('barthez_ai');
    $db->selectCharset('utf8');


    if(isset($_GET['order']) &&  $_GET['order'] == "top"){
        $aphorisms = $db->createQuery("SELECT * FROM `byone` where autorId in (SELECT id FROM aphoAuthors order by rate)")
            ->setLimit(0, 8)
            ->getResult();
    //        ->getSQL();

    }else{

    $aphorisms = $db->createQuery("SELECT * FROM `byone` order by rand()")
            ->setLimit(0, 8)
            ->getResult();
    //        ->getSQL();
    }
    $alreadyArray = array();
?>


<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <link type="text/css" rel="stylesheet" media="screen" href="styles.css" />
        <meta name="google-site-verification" content="fyuedQpG-mhkgjffEXP9LLDzJJONW3pZDdIrydWaoEQ" />
    <div id="fb-root"></div>

    <script type="text/javascript">

                    var _gaq = _gaq || [];
                    _gaq.push(['_setAccount', 'UA-19921719-1']);
                    _gaq.push(['_trackPageview']);

                    (function() {
                        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                    })();
    </script>
    </head>
    <body>
        
        <div class="mainContainer">
            
            <?foreach($aphorisms as $one):?>
                <? if(strlen($one['text'])>60 && strlen($one['text'])<180):?>
                    <img src="./asImage.php?text=<?=$one['text']?>&backId=<?=rand(1,4)?>" alt="" title=""/>
                <?endif; ?>
            <? endforeach;?>
            
        </div>
         
        
    </body>
</html>
